home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / VBSamples / DirectShow / Editing / DexterVB / modGlobalData.bas < prev    next >
Encoding:
BASIC Source File  |  2001-10-08  |  10.7 KB  |  212 lines

  1. Attribute VB_Name = "modGlobalData"
  2. '*******************************************************************************
  3. '*       This is a part of the Microsoft DXSDK Code Samples.
  4. '*       Copyright (C) 1999-2001 Microsoft Corporation.
  5. '*       All rights reserved.
  6. '*       This source code is only intended as a supplement to
  7. '*       Microsoft Development Tools and/or SDK documentation.
  8. '*       See these sources for detailed information regarding the
  9. '*       Microsoft samples programs.
  10. '*******************************************************************************
  11. Option Explicit
  12. Option Base 0
  13. Option Compare Text
  14.  
  15.  
  16. ' **************************************************************************************************************************************
  17. ' * GLOBAL INTERFACE- DATA
  18. ' *
  19. ' *
  20.             'global timeline reference in application
  21.             Global gbl_bstrLoadFile As String                        'the last file name/path opened by the user
  22.             Global gbl_colNormalEnum As Collection            'collection for maintaining node/object relational data
  23.             Global gbl_objQuartzVB As VBQuartzHelper        'helper object for rendering filtergraph's using quartz.dll
  24.             Global gbl_objTimeline As AMTimeline               'global application timeline
  25.             Global gbl_objRenderEngine As RenderEngine  'global application render engine
  26.             Global gbl_objFilterGraph As FilgraphManager  'global application filtergraph manager
  27.             Global gbl_objDexterObject As AMTimelineObj  'global application dexter object (current object in treeview)
  28.  
  29.  
  30.  
  31.  
  32. ' **************************************************************************************************************************************
  33. ' * PUBLIC INTERFACE- PROCEDURES
  34. ' *
  35. ' *
  36.             ' ******************************************************************************************************************************
  37.             ' * procedure name: Main
  38.             ' * procedure description:   Application Entry Point
  39.             ' *
  40.             ' ******************************************************************************************************************************
  41.             Public Sub Main()
  42.             Dim nStart As Long
  43.             Dim nLength As Long
  44.             Dim bstrFileName As String
  45.             Dim boolDynamic As Boolean
  46.             Dim boolPlayback As Boolean
  47.             Dim boolSmartRecomp As Boolean
  48.             Dim boolCloseOnComplete As Boolean
  49.             Dim objLocalTimeline As AMTimeline
  50.             On Local Error GoTo ErrLine
  51.             
  52.             
  53.             'inhibit dupe instances of this application
  54.             If App.PrevInstance = False Then
  55.               'initalize global data
  56.               Set gbl_objTimeline = New AMTimeline
  57.               'display the main form for the application
  58.               Load frmMain: frmMain.Move 0, 0: frmMain.Show: frmMain.Refresh
  59.             Else: Exit Sub
  60.             End If
  61.             
  62.             
  63.             'handle command line
  64.             If Command <> vbNullString Then
  65.                   'check the command line argument(s) for a valid xtl filename with double quotes
  66.                   If InStr(1, UCase(Command), Chr(34)) > 0 Then
  67.                      nStart = InStr(1, UCase(Command), Chr(34))
  68.                      nLength = InStr(nStart + 1, Command, Chr(34))
  69.                      If nLength - nStart > Len(Command) Then
  70.                         bstrFileName = Mid(Command, nStart, nLength)
  71.                      End If
  72.                      bstrFileName = Trim(LCase(Command))
  73.                          bstrFileName = Replace(bstrFileName, "/r", vbNullString)
  74.                          bstrFileName = Replace(bstrFileName, "/d", vbNullString)
  75.                          bstrFileName = Replace(bstrFileName, Chr(34), vbNullString)
  76.                          bstrFileName = Trim(bstrFileName)
  77.                          If InStr(1, bstrFileName, ".xtl") > 0 Then
  78.                             If InStr(1, bstrFileName, ".xtl") + 4 <> Len(bstrFileName) Then
  79.                                bstrFileName = Left(bstrFileName, InStr(1, bstrFileName, ".xtl") + 4)
  80.                             End If
  81.                          End If
  82.                   'check the command line argument(s) for a valid xtl filename with single quotes
  83.                   ElseIf InStr(1, UCase(Command), Chr(39)) > 0 Then
  84.                      nStart = InStr(1, UCase(Command), Chr(39))
  85.                      nLength = InStr(nStart + 1, Command, Chr(39))
  86.                      If nLength - nStart > Len(Command) Then
  87.                         bstrFileName = Mid(Command, nStart, nLength)
  88.                      End If
  89.                      bstrFileName = Trim(LCase(Command))
  90.                          bstrFileName = Replace(bstrFileName, "/r", vbNullString)
  91.                          bstrFileName = Replace(bstrFileName, "/d", vbNullString)
  92.                          bstrFileName = Replace(bstrFileName, Chr(39), vbNullString)
  93.                          bstrFileName = Trim(bstrFileName)
  94.                          If InStr(1, bstrFileName, ".xtl") > 0 Then
  95.                             If InStr(1, bstrFileName, ".xtl") + 4 <> Len(bstrFileName) Then
  96.                                bstrFileName = Left(bstrFileName, InStr(1, bstrFileName, ".xtl") + 4)
  97.                             End If
  98.                          End If
  99.                   'check the command line argument(s) for a valid xtl filename with no quotes
  100.                   Else
  101.                          bstrFileName = Trim(LCase(Command))
  102.                          bstrFileName = Replace(bstrFileName, "/r", vbNullString)
  103.                          bstrFileName = Replace(bstrFileName, "/d", vbNullString)
  104.                          bstrFileName = Trim(bstrFileName)
  105.                          If InStr(1, bstrFileName, ".xtl") > 0 Then
  106.                             If InStr(1, bstrFileName, ".xtl") + 4 <> Len(bstrFileName) Then
  107.                                bstrFileName = Left(bstrFileName, InStr(1, bstrFileName, ".xtl") + 4)
  108.                             End If
  109.                          End If
  110.                   End If
  111.                   
  112.                   'check the command line argument(s) for smart recomp optional
  113.                   If InStr(1, UCase(Command), Space(1) & "/R") > 0 Then
  114.                      boolSmartRecomp = True
  115.                   End If
  116.                   
  117.                   'check the command line argument(s) for dynamic connections optional
  118.                   If InStr(1, UCase(Command), Space(1) & "/D") > 0 Then
  119.                      boolDynamic = True
  120.                   End If
  121.                   
  122.                   'check the command line argument(s) for playback optional
  123.                   If InStr(1, UCase(Command), Space(1) & "/P") > 0 Then
  124.                      boolPlayback = True
  125.                   End If
  126.                   
  127.                   'check the command line argument(s) for close when finished optional
  128.                   If InStr(1, UCase(Command), Space(1) & "/C") > 0 Then
  129.                      boolCloseOnComplete = True
  130.                   End If
  131.             End If
  132.             
  133.                   
  134.                
  135.             'proceed to load the xtl file into the application ide and render it
  136.             If InStr(1, LCase(bstrFileName), ".xtl") > 0 Then
  137.                'at least it's been named an xtl file, proceed to attempt an import..
  138.                Set objLocalTimeline = New AMTimeline
  139.                Call RestoreTimeline(objLocalTimeline, bstrFileName, DEXImportXTL)
  140.                'verify restoration
  141.                If Not objLocalTimeline Is Nothing Then
  142.                   'import succeeded; clean-up global scope
  143.                   If Not gbl_objTimeline Is Nothing Then
  144.                      Call ClearTimeline(gbl_objTimeline)
  145.                      Set gbl_objTimeline = Nothing
  146.                   End If
  147.                   'assign the local timeline to global scope
  148.                   Set gbl_objTimeline = objLocalTimeline
  149.                   'reset application-level filename
  150.                   gbl_bstrLoadFile = bstrFileName
  151.                   'reset the caption on the application's main form
  152.                   bstrFileName = Mid(bstrFileName, InStrRev(bstrFileName, "\") + 1)
  153.                   frmMain.Caption = "DexterVB - " & bstrFileName
  154.                Else: Exit Sub
  155.                End If
  156.             End If
  157.                
  158.                
  159.             'render the timeline and derive a filter graph manager
  160.             Set gbl_objFilterGraph = RenderTimeline(gbl_objTimeline, boolDynamic, boolSmartRecomp)
  161.             Set gbl_objQuartzVB.FilterGraph = gbl_objFilterGraph
  162.             'map the timeline to the userinterface
  163.             Call GetTimelineDirect(frmMain.tvwSimpleTree, gbl_objTimeline, gbl_colNormalEnum)
  164.             frmMain.mnuTimeLineClearRenderEngine.Enabled = False
  165.             'update the button(s)
  166.             With frmMain.tbMain.Buttons
  167.                .Item("Play").Image = 6
  168.                .Item("Pause").Image = 7
  169.                .Item("Stop").Image = 22
  170.                .Item("Rewind").Image = 18
  171.                .Item("FastForward").Image = 24
  172.                .Item("SeekForward").Image = 23
  173.                .Item("SeekBackward").Image = 19
  174.                .Item("Play").Enabled = True
  175.                .Item("Pause").Enabled = True
  176.                .Item("Stop").Enabled = False
  177.                .Item("Rewind").Enabled = False
  178.                .Item("FastForward").Enabled = False
  179.                .Item("SeekForward").Enabled = False
  180.                .Item("SeekBackward").Enabled = False
  181.             End With
  182.             'update the state on the popup context menu
  183.             frmMain.mnuTimeLinePlay.Enabled = True
  184.             frmMain.mnuTimeLineStop.Enabled = False
  185.             frmMain.mnuTimeLinePause.Enabled = True
  186.             frmMain.mnuTimeLineRenderTimeLine.Enabled = False
  187.             frmMain.mnuTimeLineClearRenderEngine.Enabled = False
  188.             
  189.             If boolPlayback Then
  190.                'run the graph
  191.                Call gbl_objFilterGraph.Run
  192.                
  193.                'if optional close on complete, unload when the timeline is finished rendering..
  194.                If boolCloseOnComplete = True Then
  195.                   Do Until gbl_objQuartzVB.Position = gbl_objQuartzVB.StopTime: DoEvents: DoEvents
  196.                   If frmMain.Visible = False Then
  197.                      Exit Do
  198.                   End If
  199.                   Loop
  200.                   Unload frmMain: Set frmMain = Nothing: Exit Sub
  201.                End If
  202.             End If
  203.             
  204.             'clean-up & dereference
  205.             If Not objLocalTimeline Is Nothing Then Set objLocalTimeline = Nothing
  206.             Exit Sub
  207.             
  208. ErrLine:
  209.             Err.Clear
  210.             Exit Sub
  211.             End Sub
  212.